package admin

import (
	"exercise/application/yiran/app/libs"
	"exercise/application/yiran/app/request/adminRequest"
	"exercise/application/yiran/app/service/admin"
	"github.com/gin-gonic/gin"
)

type enrollStudentController struct {
}

// InitStudent 初始化学生
func (rcv *enrollStudentController) InitStudent(ctx *gin.Context) {
	request := new(adminRequest.EnrollStudentInitRequest)
	err := libs.BindRequest(ctx, request)

	if err != nil {
		libs.Toast(ctx, err.Error())
		return
	}
	ret, err := admin.NewEnrollStudentService(ctx).InitStudent(request)
	if err != nil {
		libs.Toast(ctx, err.Error())
		return
	}
	libs.Success(ctx, ret)
}

// UpdateScoreRanking 更新成绩排名
func (rcv *enrollStudentController) UpdateScoreRanking(ctx *gin.Context) {
	request := new(adminRequest.UpdateScoreRankingRequest)
	err := libs.BindRequest(ctx, request)

	if err != nil {
		libs.Toast(ctx, err.Error())
		return
	}

	err = admin.NewEnrollStudentService(ctx).UpdateScoreRanking(request)
	if err != nil {
		libs.Toast(ctx, err.Error())
		return
	}
	libs.OkToast(ctx, "更新成功")
}

// EarlyDecision 预录取
func (rcv enrollStudentController) EarlyDecision(ctx *gin.Context) {
	request := new(adminRequest.EarlyDecisionRequest)
	err := libs.BindRequest(ctx, request)

	if err != nil {
		libs.Toast(ctx, err.Error())
		return
	}

	list, err := admin.NewEnrollStudentService(ctx).EarlyDecision(request)
	if err != nil {
		libs.Toast(ctx, err.Error())
		return
	}
	libs.Success(ctx, list)

	//libs.OkToast(ctx, "更新成功")

}

func NewEnrollStudentController() *enrollStudentController {
	return &enrollStudentController{}
}
